﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace FileCopyer
{
    public partial class CopyNewDestForm : Form
    {
        public CopyNewDestForm()
        {
            InitializeComponent();
        }

        private void CopyNewDestForm_Load(object sender, EventArgs e)
        {
            this.textBox1.Text = GlobalConfig.Instance.NewSaveFilePath;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                this.textBox1.Text = Path.GetDirectoryName(ofd.FileName);
                GlobalConfig.Instance.NewSaveFilePath = this.textBox1.Text;
                GlobalConfig.Instance.Save();
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void textBox1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            if(e.KeyCode== Keys.Enter)
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
    }
}
